Skip to content

Support Custom Artifactory Repositories for Package Metadata#258

Open
voidpetal wants to merge 3 commits intoaboutcode-org:mainfrom
voidpetal:fix-custom-artifactory-metadata
Open

Support Custom Artifactory Repositories for Package Metadata#258
voidpetal wants to merge 3 commits intoaboutcode-org:mainfrom
voidpetal:fix-custom-artifactory-metadata

Conversation

@voidpetal
Copy link

@voidpetal voidpetal commented Jan 21, 2026

When using --index-url with a custom Artifactory repository, dependency resolution works but the packages array comes back empty. This happens because get_pypi_data_from_purl() hardcodes https://pypi.org/pypi for the JSON API endpoint. Internal packages that don't exist on PyPI.org return 404 and are silently skipped.

The fix includes deriving the JSON API base URL from the provided repository instead of hardcoding PyPI.org
It is also necessary to match distribution files by filename (standardized per PEP 427/491) instead of full URL, since URL paths can differ between Simple API and JSON API endpoints.

@voidpetal voidpetal force-pushed the fix-custom-artifactory-metadata branch 2 times, most recently from 7bae318 to 2321963 Compare January 22, 2026 10:53
Copy link
Member

@pombredanne pombredanne left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks. This PR really looks like it was in good part generated by a coding agent. I appreciate your efforts, but overall, do not force me to review code that you have not thoroughly reviewed yourself, otherwise you are effectively outsourcing AI generation review to me, a human, which could be considered bad form and not super polite or nice.

Time is a precious thing that is not a commodity for me. And reviewing AI slop is a waste of my time.

We are evolving our AI policy but at a high level:

  1. do not use AI to generate commit messages and PR bodies messages. These are used to communicate between people, so be nice and genuine: type these yourself with your own words. Here please amend your commit messages and PR body.
  2. adopt our style for commits messages and code. In particular for tests.
  3. we need doc and changelog updates
  4. do not add unused code. Remove it.

if repos:
# Convert to list if needed and use first repo's index_url
repos_list = list(repos) if not isinstance(repos, list) else repos
base_path = repos_list[0].index_url.replace("/simple", "/pypi")
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What is this doing? this is weird: what if you have 10 repos?

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good point, I initially opted out for a half-solution to get the first repository. However now I updated it to try all available repositories until it hits a success. Let me know if this aligns with your expectations.

for url_entry in response.get("urls") or []:
url = url_entry.get("url")
if url:
# Resolve relative URLs (from Artifactory) to absolute URLs
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Do you have Artifactory examples? and what about nexus or others?

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I am not aware of any public Artifactory URL to share freely.


def get_file_match_key(url: str, sha256: Optional[str] = None) -> tuple:
"""
Extract a match key (filename, sha256) for comparing distribution files.
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Use our comment style: `Return ....

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This function was unused, sorry I overlooked it..

continue

url_data = urls.get(dist_url)
url_data = urls_by_filename[filename]
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Are you sure that this will not fail?

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You're right, replaced with urls_by_filename.get(filename)

@voidpetal voidpetal force-pushed the fix-custom-artifactory-metadata branch 3 times, most recently from 3cafbe0 to 672f569 Compare March 11, 2026 10:35
@voidpetal
Copy link
Author

Hi @pombredanne,

Thanks a lot for your review!
I agree with you and I sincerely apologize for making you feel your time is wasted. I will do my best to take into consideration your advice for the future contributions. Since this is my first contribution, I hope that you can forgive me for the oversight.

I have ammended the PR and commit descriptions as you proposed and the ammended code is ready for your further review.

Please let me know if you would like me to do anything else!

@voidpetal voidpetal marked this pull request as draft March 11, 2026 13:28
@voidpetal voidpetal force-pushed the fix-custom-artifactory-metadata branch from 672f569 to e5ddeeb Compare March 11, 2026 13:42
@voidpetal voidpetal marked this pull request as ready for review March 11, 2026 13:54
@voidpetal voidpetal changed the title Support Custom PyPI-Compatible Repositories for Package Metadata Support Custom Artifactory Repositories for Package Metadata Mar 11, 2026
@voidpetal voidpetal force-pushed the fix-custom-artifactory-metadata branch 2 times, most recently from dce06d9 to 40dbfa4 Compare March 11, 2026 14:24
When using --index-url with a custom Artifactory repository, dependency
resolution works but the packages array comes back empty. This happens
because get_pypi_data_from_purl() hardcodes https://pypi.org/pypi for the
JSON API endpoint. Internal packages that don't exist on PyPI.org return
404 and are silently skipped.

The fix includes deriving the JSON API base URL from the provided
repository instead of hardcoding PyPI.org. It is also necessary to match
distribution files by filename (standardized per PEP 427/491) instead of
full URL, since URL paths can differ between Simple API and JSON API
endpoints.

Signed-off-by: Kai Hodžić <hodzic.e.k@outlook.com>
Signed-off-by: Kai Hodžić <hodzic.e.k@outlook.com>
Signed-off-by: Kai Hodžić <hodzic.e.k@outlook.com>
@voidpetal voidpetal force-pushed the fix-custom-artifactory-metadata branch from 40dbfa4 to 9fdb092 Compare March 12, 2026 07:50
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants